home *** CD-ROM | disk | FTP | other *** search
/ 2,000 Greater & Lesser Mysteries / 2,000 Greater and Lesser Mysteries.iso / internet / mys01118.txt < prev    next >
Encoding:
Text File  |  1994-06-10  |  28.0 KB  |  721 lines

  1. MUF REFERENCE MANUAL:
  2.  
  3. This manual was compiled largely from the original MUF reference manual,
  4. with help from Black_Dougal. It is intended more as a reference work than as
  5. a tutorial, and should be current through TinyMUCK 2.1.1. Please feel free to
  6. e-mail me any errata or addenda at rawdon@rex.cs.tulane.edu.    - Jethro
  7.  
  8. Updated completely for TinyMUCK release 2.2 by me -- ChupChup
  9.  
  10. DICTIONARY OF MUF EDITOR COMMANDS
  11. ---------------------------------
  12.  
  13. See @PROG and @EDIT in the MUCK Reference Sheets for information about
  14. enterting the editor.
  15.  
  16. <number> i
  17. Enter insert mode before line #i. Any number of lines may be contiguously
  18. inserted.  The old line #i will become the first line after the inserted
  19. lines.  Blank lines are ignored and do not become part of the program.
  20. Entering the character `.' (period) alone on a line (not preceded or
  21. followed by any spaces) exits insert mode. The `.' does not become a line.
  22.  
  23. <number1> <number2> l
  24. Display all lines from <number1> to <number2> inclusive. If only one <number>
  25. is given, only that line will be displayed.
  26.  
  27. <number1> <number2> d
  28. Delete all lines from <number1> to <number2> inclusive. If only one <number>
  29. is given, only that line will be deleted.
  30.  
  31. c
  32. Compile the program you are editing. This must be done before a program will
  33. run properly.
  34.  
  35. u
  36. Unassemble program. This was used to test MUF during its development. It
  37. has no real use for programmers.
  38.  
  39. n
  40. Toggle display of numbers in program listings.
  41.  
  42. q
  43. Quit from the editor. @Q may also be used to do this.
  44.  
  45. <name1> <name2> s
  46. Show macros in long format: name of macro, name of the person who entered it,
  47. and the body of the macro.  `a z s' will show all macros, for instance.
  48.  
  49. <name1> <name2> a
  50. Abridged macro display.  Shows only the names of macros.
  51.  
  52. DICTIONARY OF MUF PRIMITIVES
  53. ----------------------------
  54.  
  55. CONVENTIONS:
  56. d: database reference; i: integer; s: string; v: variable; a: function address;
  57. x, y: Any of the above.
  58.  
  59. + - * / % ( i1 i2 -- i )
  60. These words perform arithmetic operations on numbers. `+' = addition
  61. (i1 + i2); `-' = subtraction (i1 - i2); `*' = multiplication (i1 times
  62. i2, or i1 * i2); `/' = division (i1 divided by i2, or i1 / i2) with
  63. integer division truncation of fractions; `%' = modulo (remainder of
  64. i1 / i2, or i1 % i2) Please note: all these operations may also be
  65. performed where i1 is a variable type.  This is mainly useful in
  66. calculating an offset for a variable array.
  67.  
  68. < > = <= >= ( i1 i2 -- i )
  69. Performs relational operations on integers i1 and i2. These return i
  70. as 1 if the expression is true, and i as 0 otherwise.
  71.  
  72. @ ( v -- x )
  73. Retrieves variable v's value x.
  74.  
  75. ! ( x v -- )
  76. Sets variable v's value to x.
  77.  
  78. addpennies ( d i -- )
  79. d must be a player or thing object.  Adds i pennies to object d.
  80. Without Wizard permissions, addpennies may only give players pennies,
  81. limited to between zero and MAX_PENNIES.
  82.  
  83. addprop ( d s1 s2 i -- )
  84. Sets property associated with s1 in object d.  Note that if s2 is null
  85. "", then i will be used.  Otherwise, s2 is always used.  All four
  86. parameters must be on the stack; none may be omitted.  If the
  87. effective user of the program does not control the object in question
  88. and the property begins with an underscore `_', the property cannot be
  89. changed.  The same goes for properties beginning with a dot `.' which
  90. cannot be read without permission.  If you store values, you must
  91. ensure that it they are never zero.  Otherwise, when the user stores a
  92. non-zero number into the string field, (users may only access string
  93. fields) the next time TinyMUCK is dumped and loaded up again, the
  94. value field will be replaced with atoi(string field).  If it is
  95. necessary to store zero, it is safer to just add 1 to everything.
  96.  
  97. and ( x y -- i )
  98. Performs the boolean `and' operation on x and y, returning i as 1 if
  99. both i1 and i2 are TRUE, and returning i as 0 otherwise.
  100.  
  101. atoi ( s -- i )
  102. Turns string s into integer i.  If s is not a string, then 0 is pushed
  103. onto the stack.
  104.  
  105. call ( d -- ?? )
  106. Calls another program d.  d must have been compiled already. d will
  107. inherit the values of ME, LOC, TRIGGER, and all other variables.
  108.  
  109. contents ( d -- d' )
  110. Pushes the dbref of the first thing contained by d.  This dbref can
  111. then be referenced by `next' to cycle through all of the contents of
  112. d.  d may be a room or a player.
  113.  
  114. copyobj ( d -- d' )
  115. Creates a new object (returning d' on top of the stack), that is a
  116. copy of object d. Each program is allowed to create only one new
  117. object per run.
  118.  
  119. dbcmp ( d1 d2 -- i )
  120. Performs comparison of database objects d1 and d2. If they are the
  121. same object, then i is 1, otherwise i is 0.
  122.  
  123. dbref ( i -- d )
  124. Converts integer i to object reference d.
  125.  
  126. desc ( d -- s )
  127. Takes object d and returns its description (@desc) string field.
  128.  
  129. drop ( d -- s )
  130. Takes object d and returns its drop (@drop) string field.
  131.  
  132. dup ( x -- x x )
  133. Duplicates the item at the top of the stack.
  134.  
  135. execute ( a -- ?? )
  136. Executes the function pointed to by the address a on the stack.
  137.  
  138. exit ( -- )
  139. Exits from the word currently being executed, returning control to the calling
  140. word, at the statement immediately after the invokation of the call (exiting
  141. the program if applicable).
  142.  
  143. exit? ( d -- i )
  144. Returns 1 if object d is an exit object, 0 if otherwise.
  145. See also player?, program?, room?, thing?, ok?.
  146.  
  147. exits ( d -- d' )
  148. Returns the first exit in the linked exit list of room/player/object d.
  149. This list can be transversed with `next'.
  150.  
  151. explode ( s1 s2 -- ... i )
  152. s2 is the delimiter string, and s1 is the target string, which will be
  153. fragmented, with i pushed on top of the stack as the number of strings
  154. s1 was broken into.  For instance:
  155.     "Hello world" " " explode
  156. will result in
  157.     "world" "Hello" 2
  158. on the stack.  (Note that if you read these items off in order, they
  159. will come out "Hello" first, then "world".)  For TinyMUCK 2.2, s2 may
  160. be any length.  But "" (null string) is not an acceptable string for
  161. parameter s2.
  162.  
  163. fail ( d -- s )
  164. Takes object d and returns its fail (@fail) string field.
  165.  
  166. flag? ( d s -- i )
  167. Reads the flag of object d, specified by s, and returns its state: 1 =
  168. on; 0 = off.  Different flags may be supported in different
  169. installations.  flag? returns 0 for unsupported or unrecognized flags.
  170.  
  171. getlink ( d -- d' )
  172. Returns what object d is linked to, or #-1 if d is unlinked.  The
  173. interpretation of link depends on the type of d: for an exit, returns
  174. the room, player, program, action, or thing that the exit is linked
  175. to.  For a player, program, or thing, it returns its `home', and for
  176. rooms returns the drop-to.
  177.  
  178. getpropstr ( d s -- s )
  179. s must be a string. Retrieves string associated with property s in
  180. object d.  If the property is cleared, "" (null string) is returned.
  181.  
  182. getpropval ( d s -- i )
  183. s must be a string. Retrieves the integer value i associated with
  184. property s in object d. If the property is cleared, 0 is returned.
  185.  
  186. if ... [ else ... ] then ( x -- )
  187. Examines boolean value x.  If x is TRUE, the sequence of statements
  188. after the 'if' up until the `then' (or until the `else' if it is
  189. present) performed. If it is FALSE, then these statements are skipped,
  190. and if an `else' is present, the statements between the `else' and the
  191. `then' are performed.  Control continues as usual at the statement
  192. after the `then'.  Note that checking the top of the stack actually
  193. pops it, so if you want to re-use it, you should dup (see DUP) it
  194. before the if. For every IF in a word, there MUST be a THEN, and
  195. vice-versa.  ELSE is optional.
  196.  
  197. instr ( s s1 -- i )
  198. Returns the first occurrence of string s1 in string s, or -1 if s1 is
  199. not found.  See also rinstr.
  200.  
  201. int ( x -- i )
  202. Converts variable or object x to integer i.
  203.  
  204. intostr ( x -- s )
  205. x must be an integer or a dbref. Converts x into string s.
  206.  
  207. jmp ( a -- )
  208. Jumps to address a.  Used internally by the compiler for constructing
  209. else clauses, jmp cannot be generated by user code.
  210.  
  211. location ( d -- d' )
  212. Returns location of object d as object d'.
  213.  
  214. match ( s -- d )
  215. Takes string s, first checks all objects in the user's inventory, then
  216. checks all objects in the current room, as well as all exits that the
  217. player may use, and returns object d which contains string s.  If
  218. nothing is found, d = #-1. If ambiguous, d = #-2. If HOME, d = #-3.
  219.  
  220. moveto ( d1 d2 -- )
  221. Moves object d1 to object d2.
  222. MOVETO is affected by the following rules:
  223.     a) If the object being moved is !JUMP_OK and is it being moved by someone
  224.        other than the object's owner, then the moveto fails.
  225.     b) If the object being moved is a person and either the source or
  226.        destination rooms (if not owned by the person being moved) are
  227.        !JUMP_OK, the moveto fails.
  228.     c) If the object being moved is not a player, is owned by the owner of
  229.        either the source or destination rooms, and either room where the
  230.        ownership matches is !JUMP_OK, the moveto fails.
  231. The moveto succeeds under any other circumstances.  MOVETO rules
  232. follow the permissions of the current effective userid.
  233.  
  234. name ( d -- s )
  235. Takes object d and returns its name (@name) string field.
  236.  
  237. next ( d -- d' )
  238. Takes object d and returns the next thing in the linked contents/exits
  239. list of d's location.
  240.  
  241. not ( x -- i )
  242. Performs the boolean `not' operation on x, returning i as 1 if x is
  243. FALSE, and returning i as 0 otherwise.
  244.  
  245. notify ( d s -- )
  246. d must be a player object. s must be a string. Tells player d message
  247. s.  If s is null it will print nothing.
  248.  
  249. notify_except ( d1 d2 s -- )
  250. d1 must be a room object, s must be a string.  Tells everyone at
  251. location d1 except object d2 message s.  If object d2 is not a player
  252. or NOTHING (#-1) all players are notified.  If s is null it prints
  253. nothing.
  254.  
  255. number? ( s -- i )
  256. Returns 1 if string on top of the stack contains a number. Otherwise
  257. returns 0.
  258.  
  259. odrop ( d -- s )
  260. Takes object d and returns its odrop (@odrop) string field.
  261.  
  262. ofail ( d -- s )
  263. Takes object d and returns its ofail (@ofail) string field.
  264.  
  265. ok? ( x -- i )
  266. Takes x and returns 1 if x is a type dbref, as well as 0 or above,
  267. below the top of the database, and is not an object of type garbage.
  268. See also exit?, player?, program?, thing?.
  269.  
  270. or ( x y -- i )
  271. Performs the boolean `or' operation on x and y. Returns i as 1 if
  272. either x or y is TRUE, returns i as 0 otherwise.
  273.  
  274. osucc ( d -- s )
  275. Takes object d and returns its osuccess (@osucc) string field.
  276.  
  277. over ( x y -- x y x )
  278. Duplicates the second-to-top thing on the stack.  This is the same as 2 pick.
  279.  
  280. owner ( d -- d' )
  281. d is any database object. Returns d', the player object that owns d.
  282. If d is a player, d' will be the same as d.
  283.  
  284. pennies ( d -- i )
  285. Gets the amount of pennies player object d has, or the penny value of thing d.
  286.  
  287. pick ( ni ... n1 i -- ni ... n1 ni )
  288. Takes the i'th thing from the top of the stack and pushes it on the top.
  289. 1 pick is equivalent to swap, and 2 pick is equivalent to over.
  290.  
  291. player? ( d -- i )
  292. Returns 1 if object d is a player object, otherwise returns 0.
  293. See also program?, room?, thing?, exit?, ok?.
  294.  
  295. pop ( x -- )
  296. Pops the top of the stack into oblivion.
  297.  
  298. program ( d -- )
  299. Internal instruction used to set permissions on called programs.
  300. Cannot be generated directly by user code.
  301.  
  302. program? ( d -- i )
  303. Returns 1 if object d is a program, otherwise returns 0.
  304. See also player?, room?, thing?, exit?, ok?.
  305.  
  306. pronoun_sub ( d s -- s' )
  307. Takes database object d and substitutes string s according to o-message
  308. rules.  For example:
  309.   me @ "%N has lost %p marbles." pronoun_sub
  310. would return:
  311.   "Igor has lost his marbles."
  312. if the player's name was Igor and his sex were male.
  313. d does not have to be a player for the substitutions to work.
  314.  
  315. random ( -- i )
  316. Returns a random integer from 0 to the MAXINT of the system running the MUCK.
  317. In general this number is (2^31)-1 or 2,147,483,647 (2.1 billion).
  318.  
  319. read ( -- s )
  320. Reads a string s from the user. This command should not be used in a
  321. program that is locked (as opposed to linked) to an object, as the
  322. lock will always fail and print the fail messages at read time.  It
  323. cannot be used in a program associated with a room object.
  324.  
  325. remove_prop ( d s -- )
  326. Removes property s from object d.  If the property begins with an
  327. underscore, `_' or a dot `.', and the effective user does not have
  328. permission on that object, the call fails.
  329.  
  330. rinstr ( s s1 -- i )
  331. Returns the last occurrence of string s1 in string s, or -1 if s1 is
  332. not found.  See also instr.
  333.  
  334. rmatch ( d s -- d' )
  335. Takes string s, checks all objects and actions associated with object
  336. d, and returns object d' which matches that string.  For example,
  337. matches actions and inventory objects for a player object, actions on
  338. a thing object, etc.  If nothing is found, d' = #-1.  if ambiguous, d'
  339. = #-2. If HOME, d' = #-3.
  340.  
  341. room? ( d -- i )
  342. Returns 1 if object d is a room, otherwise returns 0.
  343. See also player?, program?, thing?, exit?, ok?.
  344.  
  345. rot ( x y z -- y z x )
  346. Rotates the top three things on the stack.  This is equivalent to 3 rotate.
  347.  
  348. rotate ( ni ... n1 i -- n(i-1) ... n1 ni )
  349. Rotates the top i things on the stack.
  350.  
  351. set ( d s -- )
  352. Sets flag s to object d.  Currently settable things are: abode, chown,
  353. dark, haven, jump, link, sticky.  (haven and abode are not available
  354. in some places.)  Boolean operations (e.g. `!abode') work as expected.
  355.  
  356. setdesc setdrop setfail setname setodrop setofail setosucc setsucc ( d s -- )
  357. Takes object d, and sets the string field specified to s. A program
  358. may only set string fields of objects that are owned by the effective
  359. user of the program, or any object if the program is Wizard.
  360.  
  361. strcat ( s1 s2 -- s )
  362. Concatenates two strings s1 and s2 and pushes the result s = s1s2 onto the
  363. stack.
  364.  
  365. strcmp ( s1 s2 -- i )
  366. Compares strings s1 and s2. Returns i as 0 if they are equal,
  367. otherwise returns i as the difference between the first non-matching
  368. character in the strings.  For example, "a" "z" strcmp returns 25.
  369. This function is case sensitive, unlike stringcmp.
  370. See also strncmp.
  371.  
  372. strcut ( s i -- s1 s2 )
  373. Cuts string s after its i'th character.  For example,
  374.    "Foobar" 3 strcut
  375. returns
  376.    "Foo" "bar"
  377. If i is zero or greater than the length of s, returns a null string in
  378. the first or second position, respectively.
  379.  
  380. stringcmp ( s1 s2 -- i )
  381. Compares strings s1 and s2. Returns i as 0 if they are equal,
  382. otherwise returns i as the difference between the first non-matching
  383. character in the strings.  For example, "a" "z" stringcmp returns 25.
  384. This function is not case sensitive, unlike strcmp.
  385.  
  386. strlen ( s -- i )
  387. Returns the length of string s.
  388.  
  389. strncmp ( s i -- i' )
  390. Compares the first i characters in string s.  Return value is like strcmp.
  391.  
  392. subst ( s1 s2 s3 -- s )
  393. s1 is the string to operate on, s2 is the string to change all occurences
  394. of s3 into, and s is resultant string.  For example:
  395.     "HEY_YOU_THIS_IS" " " "_" subst
  396. results in
  397.     "HEY YOU THIS IS"
  398. s2 and s3 may be of any length in TinyMUCK 2.2.
  399.  
  400. succ ( d -- s )
  401. Takes object d and returns its success (@succ) string field s.
  402.  
  403. swap ( x y -- y x )
  404. Takes objects x and y on the stack and reverses their order.
  405.  
  406. thing? ( d -- i )
  407. Returns i as 1 if object d is a thing, otherwise returns i as 0.
  408. See also player?, program?, room?, exit?, ok?.
  409.  
  410. time ( -- s m h )
  411. Returns the time of day as integers on the stack, seconds, then minutes,
  412. then hours.
  413.  
  414. var <name>
  415. Var is not a `true' primitive in that it must always be used outside
  416. words and does not alter the stack in any way. When the compiler sees
  417. a `var' statement, it allows the use of <name> as a variable in all
  418. words sequentially defined after the var declaration. See VARIABLES in
  419. the encyclopedia.
  420.  
  421. variable ( i -- v )
  422. Converts integer i to variable reference v. Of the pre-defined variables,
  423. `me' corresponds to integer 0, `loc' to 1, and `trigger' to 2. Thus:
  424.      me @
  425. and
  426.      0 variable @
  427. will do the same thing (returning the user's dbref). User-defined variables
  428. are numbered sequentially starting at 3 by the compiler. Note that these
  429. variable numbers can be used even if variables have not been formally
  430. declared, making implementation of such things as arrays conveniently easy.
  431. See @, !, and VAR.
  432.  
  433.  
  434. ENCYCLOPEDIA OF MUF TERMS
  435. -------------------------
  436.  
  437. ADDRESSES:
  438.      Each function in MUF has an address in memory.  This address can
  439. be pushed on the stack with the construct: 'function.  Thus:
  440.   'foobar
  441. will push a pointer to foobar on the stack.  It can now be put in a
  442. variable, dup'ed, pop'ed, anything.  To call the function pointed
  443. to by the address, use the EXECUTE primitive.  In actuality,
  444. "'function EXECUTE" is the same as "function".
  445.  
  446. @Q:
  447.      If a program user enters this in response to a MUF prompt
  448. (e.g. from a read statement), the program will be exited. Also, typing
  449. @Q while in the editor will exit the editor, the same as `q' will.
  450.  
  451. COMMAND-LINE ARGUMENTS:
  452.      This only applies to exits that are linked to a program, not
  453. for objects that are locked to a program or call the program by @#.
  454.      When a program is invoked by a player, this may be done with a
  455. command-line argument. This argument is pushed on the stack before the
  456. program is executed.  For example, if an exit "get" is linked to a
  457. program, typing "get flower" will invoke the program with the argument
  458. "flower" pushed on the stack. Arguments are always strings - never
  459. integers.
  460.      At invocation time, TinyMUCK will examine all exits in the
  461. room location of the user and attempt to find the exit with the
  462. longest name which will match a leftmost substring of the invocation
  463. string. For example, if the user types the invocation string "get
  464. flower", TinyMUCK will match an exit named "get flower" before
  465. matching "get". The remainder of the invocation string is pushed on
  466. the stack as one object. Thus, if "eat jelly doughnut" is matched with
  467. "eat", "jelly doughnut" will be pushed. explode can be used to
  468. separate "jelly" and "doughnut".
  469.      TinyMUCK searches for exit matches in this order: room exits,
  470. room contents exits, player inventory exits, player exits.
  471.      Even if an exact match is found (i.e., an exit named with the
  472. precise invocation string), a null string ("") is pushed on the stack.
  473. Thus, the stack ALWAYS has at least one element atop it at the
  474. begining of ANY program's execution.  See EXECUTION, LINKING, LOCKING,
  475. and, in the dictionary, EXPLODE.
  476.  
  477. COMMENTS:
  478.      Comments in MUF are surrounded by parentheses. Any characters
  479. in a program between two parentheses (e.g. `(argle)') will be ignored
  480. by the compiler, and do not count as part of the program.
  481.  
  482. DBREF:
  483.      This stands for "database reference". It refers directly to an
  484. object in the TinyMUCK database. An integer is not an acceptable
  485. substitute, but the primitive dbref (q.v. in the dictionary) will
  486. convert an integer on top of the stack into a dbref.
  487.  
  488. EXECUTION:
  489.      If a program has had an exit linked to it or had an object
  490. locked to it, then whenever someone tries to use that object, it may
  491. be executed (see LINKING and LOCKING for more details).
  492.      If a program is executed, the last word sequentially defined
  493. in the program is executed. Other words (or, indeed, other programs)
  494. may be executed by that word, or by words invoked by that word, and so
  495. on. If a word is not invoked in the sequential course of execution, it
  496. will never be executed.
  497.      Whenever a word is executed, each statement in it will be
  498. executed in sequence, from first to last. Note that statements such as
  499. IF...THEN and EXIT may alter this flow of execution, but these are
  500. exceptions to the rule.
  501.      When a program is initially executed by an exit that is linked
  502. to it, at least one word will always be on top of the stack. See
  503. COMMAND-LINE ARGUMENTS for more details. For programs executed by a
  504. locked object, in general the stack will be initially empty.
  505. See also STATEMENTS and WORDS.
  506.  
  507. EXITS:
  508.      Note that since you can both link and lock (see LINKING and
  509. LOCKING) an exit to a program, you may therefore have two programs
  510. executed per exit.
  511.  
  512. HOME:
  513.      Dbref #-3 on the stack always refers to the dbref of the home
  514. of a thing or player object.
  515.  
  516. ITERATION:
  517.   This can be accomplished through recursion. One way to do this is to
  518. use a variable as a counter. An example of iteration (also known as
  519. looping) is given at the end of these documents. See RECURSION.
  520.  
  521. LINKING:
  522.   You may @link exits (but nothing else) to a program. A program will then
  523. execute every time a player goes through that exit. Multiple exits may be
  524. linked to a single program. See EXECUTION, and various entries in the MUCK
  525. Reference Sheets including @ACTION, @LINK, @OPEN, ACTIONS and LINKING.
  526.  
  527. LOCKING:
  528.   You may @lock rooms, programs, exits, things or players to a
  529. program. A program will then execute every time a player TRIES to go
  530. through that exit or pick up that thing or look at that room. The
  531. program may define whether or not the object may be picked up or the
  532. exit traveled through. This is done by pushing 1 on top of the stack
  533. before the program terminates to indicate success, or pushing 0 to
  534. indicate failure. See EXECUTION and LINKING.
  535.  
  536. PROPERTIES:
  537.   All rooms, players and things have properties. These may be set by either
  538. players or programs. However, players may only set properties to strings,
  539. while programs may set them to either strings or integers. Thus, things
  540. such as hit points, dollars, strength, etc., can be set.
  541.   Remember, though, that players can always `@set me = :' which erases all
  542. their properties. Be prepared to always set a default value on properties.
  543.   The value 0 should never be stored in a property.
  544.   See ADDPROP, GETPROPSTR, GET PROPVAL, and REMOVE_PROP in the dictionary, as
  545. well as PROPERTIES in the MUCK Reference Sheets.
  546.  
  547. RECURSION:
  548.   A word calling itself is called a recursive call. Such calls are best
  549. handled inside the if part of an if-then block, since there should always
  550. be an "escape clause" at which the recursion terminates. The subtleties of
  551. recursion are outside the scope of these documents. I suggest you find a
  552. book on the computer language Pascal to better familiarize yourself with
  553. the concept. See WORDS, and, in the dictionary, CALL.
  554.  
  555. STACK:
  556. In MUF, all statements are pushed on the stack when a running program reaches
  557. them during execution, except primitives and user-defined words, which are
  558. executed, and variables, whose addresses are pushed on the stack (and may be
  559. operated on by the @ and ! primitives - see the dictionary). The maximum
  560. number of elements that can be pushed on the stack is about 500. See
  561. EXECUTION, STATEMENTS, VARIABLES and WORDS.
  562.  
  563. STATEMENTS:
  564.   A statement is a discrete sequence of characters. Any string of characters
  565. between double-quotes (e.g. "Hello. How are you?") is a statement. Without
  566. quotes, any string of characters between spaces is a statement. (E.g.,
  567. `Hello.' is a statement. `Hello there.' is two statements.) See STACK and
  568. WORDS.
  569.  
  570. USER:
  571.      The person using the program (as opposed to the programmer).
  572. Non-setuid programs run according to the permissions of the user
  573. rather than the programmer who wrote owns the program.  The variables
  574. ME and LOC refer to the user. See VARIABLES.
  575.  
  576. VARIABLES:
  577.      Usually, variables are not needed. A program can simply push
  578. and pop things from the stack. However, `real' variables may be
  579. defined, which can make program writing much easier. They MUST be
  580. declared outside of words using the `var' primitive (they are
  581. therefore global to all words in a program).  When a variable name is
  582. a program statement, its address is pushed on the stack. The program
  583. can then use the primitive `@' to retrieve is value, or `!'  to load a
  584. value into it.
  585.      The variables ME, LOC and TRIGGER are pre-defined in MUF. ME
  586. stores the dbref of the program's user. LOC stores the dbref of his
  587. location.  TRIGGER stores the dbref of the exit/thing which caused the
  588. program to be executed.  See USER, WORDS, and, in the dictionary, @,
  589. !, VAR and VARIABLE.
  590.  
  591. WORDS:
  592.      A word in MUF begins with a colon (`:') and ends with a
  593. semicolon (`;').  The statement after the colon is the name of the
  594. word, and the remaining statements are the actual executed code of the
  595. word.  Thus, a word's form is:
  596.         : {word name} {body of word} ;
  597.      Obviously, a program may contain many words. Calling a word is
  598. accomplished by including its name in a word. A word may not be called
  599. before it has been defined, though a word can call itself.
  600. See EXECUTION, RECURSION, STATEMENTS, and, in the dictionary, CALL.
  601.  
  602.  
  603. COMMON MUF EXECUTION ERRORS
  604. ---------------------------
  605.  
  606. Below is a list of all known errors which can arise when running a MUF
  607. program, with brief descriptions. Input on how to make this list more
  608. useful would be appreciated.
  609.  
  610.  
  611. ADDPENNIES: would exceed MAX_PENNIES.
  612. All MUCKs have a value MAX_PENNIES above which the addpennies
  613. primitive cannot add more pennies to a player's penny count.
  614.  
  615. COPYOBJ: Invalid object.
  616. The object trying to be copied is invalid in some way.
  617.  
  618. Program not compiled.
  619. All programs must be compiled before they can run. This error could occur
  620. when a program is triggered or called and has not been compiled.
  621.  
  622. SETNAME: Permission denied.
  623. Since renaming a player requires that the player's password may be supplied,
  624. MUF disallows this.
  625.  
  626. MOVETO: object can't be moved.
  627. Self explanatory. The object being moved is not JUMP_OK.
  628.  
  629. MOVETO: source (or destination) not JUMP_OK
  630. Under certain circumstances, when a MOVETO is attempted, one or both
  631. of these rooms or players must be set JUMP_OK for the command to
  632. succeed. See MOVETO in the dictionary.
  633.  
  634. Non-<type> argument:
  635. The specified command requires an argument of the specified <type> as one of
  636. its parameters, and the item on the stack in the position of that parameter is
  637. not of that <type>. Possible types that may be mismatched include: integer,
  638. object, player, room, string, variable, address.
  639. There are other errors which are similar to this error. These include:
  640. -   argument is an exit          (MOVETO)
  641. -   invalid argument type      (Arithmetic, Comparison, DBCMP, INT,
  642.                   CONTENTS, flag retreive, string field
  643.                   retreive and set, SET, RMATCH)
  644. -   invalid object          (Flag retreive)
  645. -   invalid object type          (COPYOBJ, MOVETO)
  646.  
  647. Permission denied:
  648. The problem here probably has to do with ownership of the object being
  649. acted upon. This could apply to MOVETO, SET<string field> or SET.
  650.  
  651. Program internal error:
  652. The program has been compiled improperly or the compiled code has been
  653. corrupted.  This should never happen.
  654.  
  655. Stack Overflow:
  656. An attempt was made to push an element on the stack when the stack was full.
  657.  
  658. Stack Underflow:
  659. An attempt was made to pop an element from the stack when the stack was empty.
  660.  
  661.  
  662. Examples of Basic MUF Programming Techniques
  663. --------------------------------------------
  664.  
  665. A very simple program to add 2 and 3 and print the result to the user. Note
  666. that the result must be converted to a string before the notify primitive.
  667. (Tells the user the sum of two and three                             )
  668. : simple
  669.   2 3 +                         (Add 2 + 3                           )
  670.   intostr                       (Convert to string                   )
  671.   me @ swap                     (Order of the notify primitive       )
  672.   notify ;                      (  necessitates the swap             )
  673.  
  674. ---
  675. A simple example of the if-then primitive. This word looks at the top
  676. of the stack and prints "Hello!" if it is zero, and "Goodbye..." otherwise.
  677. Note the inclusion of the 'not' primitive to do this.
  678. : greeting
  679.   not                           (Change logical value of top of stack) 
  680.   if                            (Check top of stack                  )
  681.     me @ "Hello!" notify        (If it is nonzero, do this           )
  682.     exit
  683.   then
  684.   me @ "Goodbye..." notify ;    (If it is zero, do this              )
  685.  
  686. ---
  687. A simple iterative loop:
  688.  
  689. (This word, when called with a number on top of the stack, will print)
  690. (out 'Hello world!" to the user that number of times                 )
  691. : iterator
  692.   dup 0 <=
  693.   if                             (Terminate if top of stack <= 0     )
  694.     exit
  695.   then
  696.   me @ "Hello world!" notify     (Print "Hello world!" to user       )
  697.   1 -                            (Subtract one from counter          )
  698.   iterator ;                     (Recursive call to iterator         )
  699.  
  700. ---
  701. An alternate version of the above word, using a variable instead. The
  702. variable 'counter' must have been pre-initialized to a number.
  703. var counter
  704. : iterator-2
  705.   counter @ 0 <=
  706.   if
  707.     exit                         (Terminate if counter <= 0          )
  708.   then
  709.   me @ "Hello world!" notify     (Print "Hello world!" to user       )
  710.   counter @ 1 - counter !        (Decrement counter                  )
  711.   iterator-2 ;                   (Recursive call to iterator         )
  712.  
  713. ---
  714. A random-number generator:
  715.  
  716. (This word pushes a random number from 1 to 100 on the stack)
  717. : random-100
  718.   random 100 % 1 + ;
  719.  
  720.  
  721.